<script setup>
import { ref  } from 'vue'
  
// 使用defineEmits来声明自定义事件
  const emit =  defineEmits(['play-game'])

let game = ref('英雄联盟')
function sendGame(){
   // 触发自定义事件
    emit('play-game',game.value)
}
</script>
<template>
  <div class="mychild">
    <h3>子组件</h3>
    <h3>儿子喜欢的游戏是:{{ game }}</h3>
    <el-button type="primary" @click="sendGame">子组件按钮</el-button>
    </div>
</template>
<style scoped>
.mychild {
  background-color: #1884b2;
  padding: 10px;
  border: 1px solid #000;
}
</style>